<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    p {
      text-align: center;
    }

    .wrapper {
      width: 400px;
      height: 700px;
      background: url(pic/11.jpg) no-repeat center / cover;
      margin: 0 auto;
    }

    .p {
      text-align: center;
      margin: 300px 0 0 0;
      /* transform: translateX(-50px); */
    }
  </style>
</head>

<body>
  <div class="wrapper">
    <p><strong>年会抽奖</strong></p>
    <div class="p">
      <h1>一等奖：<span id="one"></span></h1>
      <h3>二等奖：<span id="two"></span></h3>
      <h5>三等奖：<span id="three"></span></h5>
    </div>
  </div>
  <script>
    //1.声明数组
    const personArr = ['刘德华', '张学友', '黎明', '郭富城', '李晟昊']

    //2.先做一等奖
    //2.1 随机数 数组的下标
    const random1 = Math.floor(Math.random() * personArr.length)
    console.log(personArr[random1])
    //2.2 获取one元素
    const one = document.querySelector('#one')
    //2.3 把名字给one
    one.innerHTML = personArr[random1]
    //2.4 删掉数组里这个名字
    personArr.splice(random1, 1)  //把一等奖去掉
    console.log(personArr)  //检查剩余数组

    //3.二等奖
    //3.1 随机数 数组的下标
    const random2 = Math.floor(Math.random() * personArr.length)
    console.log(personArr[random2])
    //3.2 获取two元素
    const two = document.querySelector('#two')
    //3.3 把名字给two
    two.innerHTML = personArr[random2]
    //3.4 删掉数组里这个名字
    personArr.splice(random2, 1)  //把二等奖去掉
    console.log(personArr)  //检查剩余数组

    //4.二等奖
    //4.1 随机数 数组的下标
    const random3 = Math.floor(Math.random() * personArr.length)
    console.log(personArr[random3])
    //4.2 获取three元素
    const three = document.querySelector('#three')
    //4. 把名字给three
    three.innerHTML = personArr[random3]
    //4.4 删掉数组里这个名字
    personArr.splice(random3, 1)  //把二等奖去掉
    console.log(personArr)  //检查剩余数组
  </script>
</body>

</html>